package com.hospital.demo.service.impl.gaoyuran;

import com.hospital.demo.enums.ExceptionCodeEnums;
import com.hospital.demo.exception.HospitalException;
import com.hospital.demo.mapper.gaoyuran.Equipment_useMapper;
import com.hospital.demo.model.gaoyuran.Equipment_use;
import com.hospital.demo.service.gaoyuran.Equipment_useSer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class EquipmentImpl_use implements Equipment_useSer {


    @Autowired
    private Equipment_useMapper equipment_useMapper;

    @Autowired
    private Equipment_useSer equipment_useSer;


    //查看全部器材使用信息
    @Override
    public List<Equipment_use> findallequipment_use() {
        return equipment_useMapper.findAll();
    }

    //更新器材使用信息
    @Override
    public int upDateEquipment_use(Equipment_use equipment_use) {
        try {
            equipment_useMapper.updateByPrimaryKey(equipment_use);
        } catch (Exception e) {
            throw new HospitalException(ExceptionCodeEnums.UPDATE_FAIL);
        }
        return 0;
    }

    //插入器材使用信息
    @Override
    public int AddEquipment_use(Equipment_use equipment_use) {
        try {
            equipment_useMapper.insert(equipment_use);
        }catch (Exception e) {
            throw new HospitalException(ExceptionCodeEnums.INSERT_FAIL);
        }

        return 0;
    }


   //通过id删除器材信息
    @Override
    public int delEquipmentById(Integer uid) {
        return equipment_useMapper.deleteByPrimaryKey(uid);
    }

}
